<!--
 * @Author: xuna
 * @Descripttion: 回款详情
-->
<template>
  <div>
    <el-drawer
      v-if="isOpenDetail"
      title="打款详情"
      :visible.sync="isOpenDetail"
      :direction="direction"
      size="40%"
      :before-close="beforeClose"
      class="draw-panel"
    >
      <div class="detail-wrap">
        <div v-for="item in detailInfo" :key="item.label" class="detail-row">
          <span class="label">{{ item.label }}:</span>
          <span v-if="!item.type">{{ item.val }}</span>
          <img v-if="item.type && item.val" :src="item.val" alt="" />
        </div>
      </div>
    </el-drawer>
  </div>
</template>

<script>
  import { getMoneyBackDetail } from '@/api/careCard';
  export default {
    props: {
      paycolletRow: {
        type: Object,
        default() {
          return {};
        },
      },
      isOpenDetail: {
        type: Boolean,
        required: true,
      },
    },

    data() {
      return {
        direction: 'rtl',
        detailInfo: [
          {
            label: '累计分配总额',
            type: 0,
            val: 100,
          },
          {
            label: '累计回收总额',
            type: 0,
            val: 100,
          },
          {
            label: '已出账消费总额',
            type: 0,
            val: 100,
          },
          {
            label: '充值回款金额',
            type: 0,
            val: 100,
          },
          {
            label: '打款回执',
            type: 1,
            val: '',
          },

          {
            label: '备注',
            type: 0,
            val: '03295823058@163.com',
          },
        ],
      };
    },
    watch: {
      paycolletRow(newDtat) {
        if (newDtat) {
          this.initDetail(newDtat);
        }
      },
    },
    activated() {},
    methods: {
      beforeClose() {
        this.$emit('closeDrawer', false);
      },
      initDetail() {
        getMoneyBackDetail(this.paycolletRow.id).then(res => {
          if (res.status == 200) {
            console.log(res);
            let detailInfo = res.data;
            this.detailInfo[0].val = detailInfo.totalAmount;
            this.detailInfo[1].val = detailInfo.totalRecoverAmount;
            this.detailInfo[2].val = detailInfo.billTotalAmount;
            this.detailInfo[3].val = detailInfo.amount;
            this.detailInfo[4].val = detailInfo.filePaths.length
              ? detailInfo.filePaths[0].filePath
              : '';
            this.detailInfo[5].val = detailInfo.remarks;
          }
        });
      },
    },
  };
</script>

<style lang="scss" scoped>
  @import '~@/styles/mixin.scss';

  .demo-ruleForm {
    height: 100%;
  }
  .draw-panel {
    /deep/.el-drawer {
      border-radius: 14px 0 0 14px;
    }
    /deep/.el-drawer__header {
      display: flex;
      align-items: center;
      @include font(16px, #34363b, bold);
      height: 60px;
      background: rgba(255, 255, 255, 1);
      box-shadow: 0px 1px 12px 0px rgba(194, 194, 198, 0.31);
      padding: 0 0 0 14px;
    }
    /deep/.el-drawer__body {
      padding: 16px 28px 0 37px;
      box-sizing: border-box;
      overflow-y: auto;
    }
    .detail-row {
      margin-top: 30px;
      display: flex;
      > img {
        @include wh(208px, 123px);
        vertical-align: top;
      }
      span {
        @include font(14px, #1e2023, 400);
        &.label {
          width: 18%;
          text-align: right;
          @include font(14px, #7f848b, 400);
          margin-right: 21px;
        }
      }
    }
  }
</style>
